/**
 * Copyright (c) 2018, wuyy All rights reserved.
 * wuyy 专有/保密源代码,未经许可禁止任何人通过任何渠道使用、修改源代码.
 * QQ:16349023
 * 项目名称 : com.wy2.eclipse.tool.ui
 * @version V1.0
 */
package com.wy2.eclipse.tool.ui.editors;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import com.wy2.eclipse.tool.ui.PluginUIImages;
import com.wy2.generator.database.entity.DatabaseColumn;
import com.wy2.generator.database.entity.DatabaseTable;

/**
 * 数据表标签提供者
 * @author wuyy<16349023@qq.com>
 * @date 2018年1月21日上午9:56:58
 * 
 */
public class TableLabelProvider implements ITableLabelProvider {

    /** 
     * @param listener 
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
     */
    @Override
    public void addListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub

    }

    /** 
     *  
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
     */
    @Override
    public void dispose() {
        // TODO Auto-generated method stub

    }

    /** 
     * @param element
     * @param property
     * @return 
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
     */
    @Override
    public boolean isLabelProperty(Object element, String property) {
        // TODO Auto-generated method stub
        return false;
    }

    /** 
     * @param listener 
     * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
     */
    @Override
    public void removeListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub

    }

    /** 
     * @param element
     * @param columnIndex
     * @return 
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
     */
    @Override
    public Image getColumnImage(Object element, int columnIndex) {
        if((element instanceof DatabaseTable) && columnIndex==0 ) {
            return PluginUIImages.ABOUT_DIALOG_ICON_TITLE;
        }
        return null;
    }

    /** 
     * @param element
     * @param columnIndex
     * @return 
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
     */
    @Override
    public String getColumnText(Object element, int columnIndex) {
        if(element instanceof DatabaseTable) {
            DatabaseTable table=(DatabaseTable) element;
            switch (columnIndex) {
                case 0:
                    return table.getSqlName();
                case 1:
                    return table.getEntityName();
                case 3:
                    return table.getModule();
                default:
                    break;
            }
        }else if(element instanceof DatabaseColumn) {
            DatabaseColumn column=(DatabaseColumn) element;
            switch (columnIndex) {
                case 0:
                    return column.getSqlName();
                case 1:
                    return column.getJavaProperty();
                case 2:
                    return column.getFullJavaType();
                default:
                    break;
            }
        }
        return "";
    }

}
